package com.study.utils;

import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;

import javafx.application.Platform;


/**由于JDK中的系统托盘类 SystemStray （AWT中的） 不能地退出，故自己实现一个
 * 参考：https://blog.csdn.net/why_su/article/details/90703123
*@description
*@author xtayhame
*date 2020年3月19日
*version
*since v1.0
*/
public class CustomerSystemStray {
	private static SystemTray  systemTray;
	private static TrayIcon trayIcon;
	private static Image image;
	private static String tooltip="小蚂蚁管家";
	private static PopupMenu popupMenu;
	private static MenuItem showMenuItem;  //展示
	private static MenuItem exitMenuItem;  //退出

	private static ActionListener showListener;
	private static ActionListener exitListener;
	private static MouseListener  mouseListener;

	private static CustomerSystemStray install;


	static{
		//设置非直接退出
		Platform.setImplicitExit(true);
		systemTray.getSystemTray();
		image = Toolkit.getDefaultToolkit().createImage("src/icon/01.jpg");
		popupMenu = new PopupMenu();
		showMenuItem = new MenuItem("打开");
		exitMenuItem = new MenuItem("退出");
		trayIcon = new TrayIcon(image, tooltip, popupMenu);


	}


	public CustomerSystemStray getInstance(){
		if(install !=null){
			install = new CustomerSystemStray();
		}
		return install;
	}

	private CustomerSystemStray() {

	}




}
